import java.util.Scanner;

 class Demo {
    static class TreeNode {
        char val;
        TreeNode left;
        TreeNode right;
        TreeNode(char val){
            this.val = val;
        }
    }
   static int  i = 0;
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextLine()) { // 注意 while 处理多个 case
           String sc = in.nextLine();
           TreeNode root = createTree(sc);
        }
    }
    public static TreeNode createTree(String sc){
        TreeNode root = null;
        if(sc.charAt(i)!='#'){
            i++;
            root = new TreeNode(sc.charAt(i));
            root.left = createTree(sc);
            root.right = createTree(sc);
        }else{
            i++;
        }
        return root;
    }
    public static void inorder(TreeNode root){
        if(root == null){
            return;
        }
        inorder(root.left);
        System.out.print(root.val+" ");
        inorder(root.right);
    }
}